<?php include_once("header.html"); ?>

<head>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>system/application/styles/admin_view_add.css" />
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<meta name="generator" content="Geany 0.16" />
    <script type="text/javascript">
        function select(what, field, idfield)
        {
            var url = '<?php echo site_url('admin/content/select'); ?>';
            w=window.open(url.concat('/', what, '/0'),'name','height=600,width=800');
            w.field = field;
            w.idfield = idfield;
            w.focus();
            return false;
        }
        function setField(field, idfield, name, id)
        {
            if (field && idfield)
            {
                field.value = name;
                idfield.value = id;
            }
            window.focus();
        }
    </script>
</head>

<body>
	<div id="space">
		<div id="picture">
			<img src="<?php echo base_url(); ?>system/application/styles/name1.png"></a>
  		</div>
   		<div id="table">
	
    <?php

        echo validation_errors();
        
        echo form_open('admin/form/submit_modify', array('name' => 'form'));
       
        if ($table == 'teacher' || $table == 'parentt' || $table == 'student'):
            echo form_label('Imię', 'firstname');
            echo form_input('firstname', is_null($record) ? set_value('firstname') : $record->firstname);
            ?><br />
            
            <?php echo form_label('Nazwisko', 'secondname');
            echo form_input('secondname', is_null($record) ? set_value('secondname') : $record->secondname);
            ?><br />
            
            <?php
            echo form_label('Email', 'email');
            echo form_input('email', is_null($record) ? set_value('email') : $record->email);
            ?><br />
            <?php
        endif;
        
        switch ($table):
            case 'classe':
                echo form_label('Nazwa klasy', 'name');
                echo form_input('name', is_null($record) ? set_value('name') : $record->name);
                ?><br />
                <?php
                break;
            case 'teacher':
                echo form_label('Numer telefonu', 'telephone');
                echo form_input('telephone', is_null($record) ? set_value('telephone') : $record->telephone);
                ?><br />
                 
	    	    <?php 
                echo form_label('Wychowawca klasy', 'master');
                echo form_input(array(  'name' => 'classe', 'readonly'=>'',
                                        'value' => is_null($record) ? set_value('classe') : $related['classe']));
                echo "<br>";
                echo form_hidden('classe_id', is_null($record) ? set_value('classe_id') : $related['classe_id']);
                $js = 'onClick="select(\'classe_master\', document.form.classe, document.form.classe_id)"';
                echo form_button('master_b', 'Wybierz klasę', $js);
                ?><br />
                
	        	<?php
                echo form_label('Uczy przedmiotu', 'subject');
                echo form_input(array(  'name' => 'subject', 'readonly'=>'',
                                        'value' => is_null($record) ? set_value('subject') : $related['subject']));
                echo "<br>";
                echo form_hidden('subject_id', is_null($record) ? set_value('subject_id') : $related['subject_id']);
                $js = 'onClick="select(\'subject\', document.form.subject, document.form.subject_id)"';
                echo form_button('subject_b', 'Wybierz przedmiot', $js);
                ?><br />
                
                <?php                
                echo form_label('W klasach', 'classes');
                echo form_textarea(array(   'name' => 'classes', 'readonly'=>'', 'rows' => '3', 'cols' => '40',
                                            'value' => is_null($record) ? set_value('classes') : implode("\n", $related['classes'])));
                echo "<br>";
                echo form_hidden('classes_id', is_null($record) ? set_value('classes_id') : implode(';', $related['classes_id']));
                $js = 'onClick="select(\'classe_subjects\', document.form.classes, document.form.classes_id)"';
                echo form_button('classes_b', 'Wybierz klasy', $js);
                ?><br />
                
                <?php
                break;
            case 'subject':
                echo form_label('Nazwa przedmiotu', 'name');
                echo form_input('name', is_null($record) ? set_value('name') : $record->name);
                ?><br />
                <?php
                break;
            case 'student':
                echo form_label('Data urodzenia (RRRR-MM-DD)', 'birth');
                echo form_input('birth', is_null($record) ? set_value('birth') : $record->birth);
                ?><br />
                
		        <?php                
                echo form_label('Należy do klasy', 'classe');
                echo form_input(    array('name' => 'classe', 'readonly'=>'',
                                    'value' => is_null($record) ? set_value('classe') : $related['classe']));
                echo "<br>";
                echo form_hidden('classe_id', is_null($record) ? set_value('classe_id') : $related['classe_id']);
                $js = 'onClick="select(\'classe_student\', document.form.classe, document.form.classe_id)"';
                echo form_button('student_b', 'Wybierz klasę', $js);
                ?><br />
                <?php
                break;
            case 'parentt':
                echo form_label('Numer telefonu', 'telephone');
                echo form_input('telephone', is_null($record) ? set_value('telephone') : $record->telephone);
                ?><br />
                
		        <?php                
                echo form_label('Adres', 'address');
                echo form_textarea(array(   'name' => 'address', 'rows' => '3', 'cols' => '40',
                                            'value' => is_null($record) ? set_value('address') : $record->address));
                ?><br />

                <?php                
                echo form_label('Lista dzieci', 'student');
                echo form_textarea(array(   'name' => 'student', 'readonly'=>'', 'rows' => '3',
                                            'cols' => '40', 'value' => is_null($record) ?
                                            set_value('student') : implode("\n", $related['student'])));
                echo "<br>";
                echo form_hidden('student_id', is_null($record) ? set_value('student_id') : implode(';', $related['student_id']));
                $js = 'onClick="select(\'student\', document.form.student, document.form.student_id)"';
                echo form_button('parentt_b', 'Wybierz dzieci', $js);
                ?><br />
                <?php
                break;
        endswitch;
        
        if (! is_null($record)):
            echo form_hidden('id', $record->id);
        else:
            echo form_hidden('id', $id);
        endif;
        echo form_hidden('table', $table);
        echo form_submit('submit', 'Zmień');
        echo form_close();

    ?>
		</div>
  	</div>
</body>


